package mediator.pattern.demo;

/**
 * Created by 逸足天涯
 * Date: 2019/10/17.
 * Time: 14:14
 */
public class ConcreteMediator extends Mediator {
    private Friend1 friend1;
    private Friend2 friend2;
    private Boss boos;

    public void setFriend1(Friend1 friend1) {
        this.friend1 = friend1;
    }

    public void setFriend2(Friend2 friend2) {
        this.friend2 = friend2;
    }

    public void setBoos(Boss boos) {
        this.boos = boos;
    }

    @Override
    public void send(Friend friend, String message) {
       if (friend == friend1){
           friend2.notify(message);
           boos.notify(friend1.name + "sends message to " + friend2.name);
       }
        if (friend == friend2){
            friend1.notify(message);
            boos.notify(friend2.name + "sends message to " + friend1.name);
        }
       if (friend == boos){
           friend1.notify(message);
           friend2.notify(message);

       }
    }
}
